package com.dj.dormitory.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dj.dormitory.entity.Building;
import com.dj.dormitory.entity.req.BuildingReq;
import com.dj.dormitory.entity.vo.BuildingVo;
import com.dj.dormitory.mapper.BuildingMapper;
import com.dj.dormitory.service.BuildingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 楼宇 服务实现类
 * </p>
 *
 * @author DJ同学
 * @since 2021-01-24
 */
@Service
public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> implements BuildingService {

    @Override
    public Map<String, Object> getList(BuildingReq buildingReq) {
        Page<BuildingVo> page = new Page<>(buildingReq.getPage(),buildingReq.getLimit());
        List<BuildingVo> list = this.baseMapper.getBuildingList(page,buildingReq);
        Map map = new HashMap();
        map.put("buildings",list);
        map.put("count",page.getTotal());
        return map;
    }
}
